<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.14"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>BabyOS: b_os.c Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="2.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">BabyOS
   &#160;<span id="projectnumber">V1.1.0</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.14 -->
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',false,false,'search.php','Search');
});
/* @license-end */</script>
<div id="main-nav"></div>
<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_b9223522bb56aee4ab59f7ba381d2163.html">bos</a></li><li class="navelem"><a class="el" href="dir_f2a2cc749b6bfcea90db6730434b0bd6.html">core</a></li><li class="navelem"><a class="el" href="dir_7991448cbe81caff9afaadef11b942e8.html">src</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">b_os.c</div>  </div>
</div><!--header-->
<div class="contents">
<a href="b__os_8c.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;</div><div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;<span class="comment">/*Includes ----------------------------------------------*/</span></div><div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="b__os_8h.html">b_os.h</a>&quot;</span></div><div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;</div><div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;<span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="group___b_o_s___private___macros.html#ga1e55aed6efd8f6dbaec02548c6ba6b71">bErrorCore</a>(<span class="keywordtype">void</span>);</div><div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160;<span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="group___b_o_s___private___macros.html#gafd10a1af74782220922eed6542324cd2">bBatteryCore</a>(<span class="keywordtype">void</span>);</div><div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;<span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="group___b_o_s___private___macros.html#gac0d4745672830bff370171057109399d">bXmodem128Timeout</a>(<span class="keywordtype">void</span>);</div><div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;<span class="keyword">extern</span> <span class="keywordtype">void</span> <a class="code" href="group___b_o_s___private___macros.html#ga519c12a30fd01012295f26bd4d153828">bYmodemTimeout</a>(<span class="keywordtype">void</span>);</div><div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;<span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="group___b_o_s___private___macros.html#ga26365b33e6409bf4f159c8d05ec5b4e0">bEventCore</a>(<span class="keywordtype">void</span>);</div><div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;<span class="keyword">extern</span> <span class="keywordtype">int</span> <a class="code" href="group___b_o_s___private___macros.html#gaf9afd0ae30f6af580ac18395a04d2fb8">bTX_Core</a>(<span class="keywordtype">void</span>);</div><div class="line"><a name="l00118"></a><span class="lineno"><a class="line" href="group___b_o_s___exported___functions.html#ga77d7bd12027132a4366d65f361d09503">  118</a></span>&#160;<span class="keywordtype">int</span> <a class="code" href="group___b_o_s___exported___functions.html#ga77d7bd12027132a4366d65f361d09503">bInit</a>()</div><div class="line"><a name="l00119"></a><span class="lineno">  119</span>&#160;{</div><div class="line"><a name="l00120"></a><span class="lineno">  120</span>&#160;    <a class="code" href="group___h_a_l___exported___functions.html#ga67c9cec578e4150ae30c526e88e60f97">bHalInit</a>();</div><div class="line"><a name="l00121"></a><span class="lineno">  121</span>&#160;    <a class="code" href="b__config_8h.html#afc78b16ad8aebf30b9cabfc278cfb32a">b_log</a>(<span class="stringliteral">&quot;device number:%d\r\n&quot;</span>, <a class="code" href="group___d_e_v_i_c_e___exported___types_definitions.html#gga1793ffbad2239c36ab43090841cf9fdaab886891c64c883dc4b308e9b165fa571">bDEV_MAX_NUM</a>);</div><div class="line"><a name="l00122"></a><span class="lineno">  122</span>&#160;    <span class="keywordflow">return</span> <a class="code" href="group___d_e_v_i_c_e___exported___functions.html#ga404e753d491d3b3e4c6fba215d191fa7">bDeviceInit</a>();</div><div class="line"><a name="l00123"></a><span class="lineno">  123</span>&#160;}</div><div class="line"><a name="l00124"></a><span class="lineno">  124</span>&#160;</div><div class="line"><a name="l00131"></a><span class="lineno"><a class="line" href="group___b_o_s___exported___functions.html#gafdd4a2c4634d1ddef0eb287cd9d76ebc">  131</a></span>&#160;<span class="keywordtype">int</span> <a class="code" href="group___b_o_s___exported___functions.html#gafdd4a2c4634d1ddef0eb287cd9d76ebc">bExec</a>()</div><div class="line"><a name="l00132"></a><span class="lineno">  132</span>&#160;{</div><div class="line"><a name="l00133"></a><span class="lineno">  133</span>&#160;<span class="preprocessor">#if _BATTERY_ENABLE</span></div><div class="line"><a name="l00134"></a><span class="lineno">  134</span>&#160;    <span class="keyword">static</span> uint32_t b_tick = 0xffffffff - <a class="code" href="b__config_8h.html#a2a5407e0aa9657e56f1d69fb83413899">MS2TICKS</a>(<a class="code" href="b__config_8h.html#a820b2107e2a1c902047d627e200049f1">_BATTERY_D_CYCLE</a>);</div><div class="line"><a name="l00135"></a><span class="lineno">  135</span>&#160;    <span class="keywordflow">if</span>(<a class="code" href="group___u_t_i_l_s___exported___functions.html#gac8e750b2b439b1cc756a4076503738e4">bHalGetTick</a>() - b_tick &gt; (<a class="code" href="b__config_8h.html#a2a5407e0aa9657e56f1d69fb83413899">MS2TICKS</a>(<a class="code" href="b__config_8h.html#a820b2107e2a1c902047d627e200049f1">_BATTERY_D_CYCLE</a>)))</div><div class="line"><a name="l00136"></a><span class="lineno">  136</span>&#160;    {</div><div class="line"><a name="l00137"></a><span class="lineno">  137</span>&#160;        b_tick = <a class="code" href="group___u_t_i_l_s___exported___functions.html#gac8e750b2b439b1cc756a4076503738e4">bHalGetTick</a>();</div><div class="line"><a name="l00138"></a><span class="lineno">  138</span>&#160;        <a class="code" href="group___b_o_s___private___macros.html#gafd10a1af74782220922eed6542324cd2">bBatteryCore</a>();</div><div class="line"><a name="l00139"></a><span class="lineno">  139</span>&#160;    }</div><div class="line"><a name="l00140"></a><span class="lineno">  140</span>&#160;<span class="preprocessor">#endif  </span></div><div class="line"><a name="l00141"></a><span class="lineno">  141</span>&#160;</div><div class="line"><a name="l00142"></a><span class="lineno">  142</span>&#160;<span class="preprocessor">#if _ERROR_MANAGE_ENABLE</span></div><div class="line"><a name="l00143"></a><span class="lineno">  143</span>&#160;    <span class="keyword">static</span> uint32_t e_tick = 0;</div><div class="line"><a name="l00144"></a><span class="lineno">  144</span>&#160;    <span class="keywordflow">if</span>(<a class="code" href="group___u_t_i_l_s___exported___functions.html#gac8e750b2b439b1cc756a4076503738e4">bHalGetTick</a>() - e_tick &gt; (<a class="code" href="b__config_8h.html#a2a5407e0aa9657e56f1d69fb83413899">MS2TICKS</a>(1000)))</div><div class="line"><a name="l00145"></a><span class="lineno">  145</span>&#160;    {</div><div class="line"><a name="l00146"></a><span class="lineno">  146</span>&#160;        e_tick = <a class="code" href="group___u_t_i_l_s___exported___functions.html#gac8e750b2b439b1cc756a4076503738e4">bHalGetTick</a>();</div><div class="line"><a name="l00147"></a><span class="lineno">  147</span>&#160;        <a class="code" href="group___b_o_s___private___macros.html#ga1e55aed6efd8f6dbaec02548c6ba6b71">bErrorCore</a>();</div><div class="line"><a name="l00148"></a><span class="lineno">  148</span>&#160;    }</div><div class="line"><a name="l00149"></a><span class="lineno">  149</span>&#160;<span class="preprocessor">#endif</span></div><div class="line"><a name="l00150"></a><span class="lineno">  150</span>&#160;</div><div class="line"><a name="l00151"></a><span class="lineno">  151</span>&#160;<span class="preprocessor">#if _XMODEM128_ENABLE</span></div><div class="line"><a name="l00152"></a><span class="lineno">  152</span>&#160;    <a class="code" href="group___b_o_s___private___macros.html#gac0d4745672830bff370171057109399d">bXmodem128Timeout</a>();</div><div class="line"><a name="l00153"></a><span class="lineno">  153</span>&#160;<span class="preprocessor">#endif</span></div><div class="line"><a name="l00154"></a><span class="lineno">  154</span>&#160;</div><div class="line"><a name="l00155"></a><span class="lineno">  155</span>&#160;<span class="preprocessor">#if _YMODEM_ENABLE</span></div><div class="line"><a name="l00156"></a><span class="lineno">  156</span>&#160;    <a class="code" href="group___b_o_s___private___macros.html#ga519c12a30fd01012295f26bd4d153828">bYmodemTimeout</a>();</div><div class="line"><a name="l00157"></a><span class="lineno">  157</span>&#160;<span class="preprocessor">#endif</span></div><div class="line"><a name="l00158"></a><span class="lineno">  158</span>&#160;</div><div class="line"><a name="l00159"></a><span class="lineno">  159</span>&#160;<span class="preprocessor">#if _FLEXIBLEBUTTON_ENABLE</span></div><div class="line"><a name="l00160"></a><span class="lineno">  160</span>&#160;    <span class="keyword">static</span> uint32_t fb_tick = 0;</div><div class="line"><a name="l00161"></a><span class="lineno">  161</span>&#160;    <span class="keywordflow">if</span>(<a class="code" href="group___u_t_i_l_s___exported___functions.html#gac8e750b2b439b1cc756a4076503738e4">bHalGetTick</a>() - fb_tick &gt;= (<a class="code" href="b__config_8h.html#ae2076738df8e2eff78366a0187291367">_TICK_FRQ_HZ</a> / <a class="code" href="b__config_8h.html#a960e9142c53f0cc0f91df72400a774bc">FLEX_BTN_SCAN_FREQ_HZ</a>))</div><div class="line"><a name="l00162"></a><span class="lineno">  162</span>&#160;    {</div><div class="line"><a name="l00163"></a><span class="lineno">  163</span>&#160;        fb_tick = <a class="code" href="group___u_t_i_l_s___exported___functions.html#gac8e750b2b439b1cc756a4076503738e4">bHalGetTick</a>();</div><div class="line"><a name="l00164"></a><span class="lineno">  164</span>&#160;        flex_button_scan();</div><div class="line"><a name="l00165"></a><span class="lineno">  165</span>&#160;    }</div><div class="line"><a name="l00166"></a><span class="lineno">  166</span>&#160;<span class="preprocessor">#endif</span></div><div class="line"><a name="l00167"></a><span class="lineno">  167</span>&#160;</div><div class="line"><a name="l00168"></a><span class="lineno">  168</span>&#160;</div><div class="line"><a name="l00169"></a><span class="lineno">  169</span>&#160;<span class="preprocessor">#if _EVENT_MANAGE_ENABLE</span></div><div class="line"><a name="l00170"></a><span class="lineno">  170</span>&#160;    <a class="code" href="group___b_o_s___private___macros.html#ga26365b33e6409bf4f159c8d05ec5b4e0">bEventCore</a>();</div><div class="line"><a name="l00171"></a><span class="lineno">  171</span>&#160;<span class="preprocessor">#endif    </span></div><div class="line"><a name="l00172"></a><span class="lineno">  172</span>&#160;    </div><div class="line"><a name="l00173"></a><span class="lineno">  173</span>&#160;<span class="preprocessor">#if _TX_ENABLE</span></div><div class="line"><a name="l00174"></a><span class="lineno">  174</span>&#160;    <a class="code" href="group___b_o_s___private___macros.html#gaf9afd0ae30f6af580ac18395a04d2fb8">bTX_Core</a>();</div><div class="line"><a name="l00175"></a><span class="lineno">  175</span>&#160;<span class="preprocessor">#endif</span></div><div class="line"><a name="l00176"></a><span class="lineno">  176</span>&#160;    <span class="keywordflow">return</span> 0;</div><div class="line"><a name="l00177"></a><span class="lineno">  177</span>&#160;}</div><div class="line"><a name="l00178"></a><span class="lineno">  178</span>&#160;</div><div class="line"><a name="l00179"></a><span class="lineno">  179</span>&#160;</div><div class="line"><a name="l00180"></a><span class="lineno">  180</span>&#160;</div><div class="line"><a name="l00193"></a><span class="lineno">  193</span>&#160;<span class="comment">/************************ Copyright (c) 2019 Bean *****END OF FILE****/</span></div><div class="line"><a name="l00194"></a><span class="lineno">  194</span>&#160;</div><div class="line"><a name="l00195"></a><span class="lineno">  195</span>&#160;</div><div class="line"><a name="l00196"></a><span class="lineno">  196</span>&#160;</div><div class="line"><a name="l00197"></a><span class="lineno">  197</span>&#160;</div><div class="ttc" id="group___b_o_s___exported___functions_html_gafdd4a2c4634d1ddef0eb287cd9d76ebc"><div class="ttname"><a href="group___b_o_s___exported___functions.html#gafdd4a2c4634d1ddef0eb287cd9d76ebc">bExec</a></div><div class="ttdeci">int bExec(void)</div><div class="ttdoc">Call this function inside the while(1) </div><div class="ttdef"><b>Definition:</b> <a href="b__os_8c_source.html#l00131">b_os.c:131</a></div></div>
<div class="ttc" id="group___u_t_i_l_s___exported___functions_html_gac8e750b2b439b1cc756a4076503738e4"><div class="ttname"><a href="group___u_t_i_l_s___exported___functions.html#gac8e750b2b439b1cc756a4076503738e4">bHalGetTick</a></div><div class="ttdeci">uint32_t bHalGetTick()</div><div class="ttdef"><b>Definition:</b> <a href="b__utils_8c_source.html#l00125">b_utils.c:125</a></div></div>
<div class="ttc" id="b__config_8h_html_a960e9142c53f0cc0f91df72400a774bc"><div class="ttname"><a href="b__config_8h.html#a960e9142c53f0cc0f91df72400a774bc">FLEX_BTN_SCAN_FREQ_HZ</a></div><div class="ttdeci">#define FLEX_BTN_SCAN_FREQ_HZ</div><div class="ttdef"><b>Definition:</b> <a href="b__config_8h_source.html#l00222">b_config.h:222</a></div></div>
<div class="ttc" id="b__config_8h_html_a2a5407e0aa9657e56f1d69fb83413899"><div class="ttname"><a href="b__config_8h.html#a2a5407e0aa9657e56f1d69fb83413899">MS2TICKS</a></div><div class="ttdeci">#define MS2TICKS(m)</div><div class="ttdef"><b>Definition:</b> <a href="b__config_8h_source.html#l00051">b_config.h:51</a></div></div>
<div class="ttc" id="group___b_o_s___private___macros_html_gafd10a1af74782220922eed6542324cd2"><div class="ttname"><a href="group___b_o_s___private___macros.html#gafd10a1af74782220922eed6542324cd2">bBatteryCore</a></div><div class="ttdeci">int bBatteryCore(void)</div></div>
<div class="ttc" id="group___b_o_s___private___macros_html_gac0d4745672830bff370171057109399d"><div class="ttname"><a href="group___b_o_s___private___macros.html#gac0d4745672830bff370171057109399d">bXmodem128Timeout</a></div><div class="ttdeci">void bXmodem128Timeout(void)</div></div>
<div class="ttc" id="group___h_a_l___exported___functions_html_ga67c9cec578e4150ae30c526e88e60f97"><div class="ttname"><a href="group___h_a_l___exported___functions.html#ga67c9cec578e4150ae30c526e88e60f97">bHalInit</a></div><div class="ttdeci">void bHalInit()</div><div class="ttdef"><b>Definition:</b> <a href="b__hal_8c_source.html#l00134">b_hal.c:134</a></div></div>
<div class="ttc" id="group___b_o_s___private___macros_html_ga26365b33e6409bf4f159c8d05ec5b4e0"><div class="ttname"><a href="group___b_o_s___private___macros.html#ga26365b33e6409bf4f159c8d05ec5b4e0">bEventCore</a></div><div class="ttdeci">int bEventCore(void)</div></div>
<div class="ttc" id="group___d_e_v_i_c_e___exported___types_definitions_html_gga1793ffbad2239c36ab43090841cf9fdaab886891c64c883dc4b308e9b165fa571"><div class="ttname"><a href="group___d_e_v_i_c_e___exported___types_definitions.html#gga1793ffbad2239c36ab43090841cf9fdaab886891c64c883dc4b308e9b165fa571">bDEV_MAX_NUM</a></div><div class="ttdef"><b>Definition:</b> <a href="b__device_8h_source.html#l00151">b_device.h:151</a></div></div>
<div class="ttc" id="b__config_8h_html_afc78b16ad8aebf30b9cabfc278cfb32a"><div class="ttname"><a href="b__config_8h.html#afc78b16ad8aebf30b9cabfc278cfb32a">b_log</a></div><div class="ttdeci">#define b_log(...)</div><div class="ttdef"><b>Definition:</b> <a href="b__config_8h_source.html#l00232">b_config.h:232</a></div></div>
<div class="ttc" id="b__config_8h_html_a820b2107e2a1c902047d627e200049f1"><div class="ttname"><a href="b__config_8h.html#a820b2107e2a1c902047d627e200049f1">_BATTERY_D_CYCLE</a></div><div class="ttdeci">#define _BATTERY_D_CYCLE</div><div class="ttdef"><b>Definition:</b> <a href="b__config_8h_source.html#l00066">b_config.h:66</a></div></div>
<div class="ttc" id="group___b_o_s___private___macros_html_ga519c12a30fd01012295f26bd4d153828"><div class="ttname"><a href="group___b_o_s___private___macros.html#ga519c12a30fd01012295f26bd4d153828">bYmodemTimeout</a></div><div class="ttdeci">void bYmodemTimeout(void)</div></div>
<div class="ttc" id="b__config_8h_html_ae2076738df8e2eff78366a0187291367"><div class="ttname"><a href="b__config_8h.html#ae2076738df8e2eff78366a0187291367">_TICK_FRQ_HZ</a></div><div class="ttdeci">#define _TICK_FRQ_HZ</div><div class="ttdef"><b>Definition:</b> <a href="b__config_8h_source.html#l00050">b_config.h:50</a></div></div>
<div class="ttc" id="group___b_o_s___exported___functions_html_ga77d7bd12027132a4366d65f361d09503"><div class="ttname"><a href="group___b_o_s___exported___functions.html#ga77d7bd12027132a4366d65f361d09503">bInit</a></div><div class="ttdeci">int bInit(void)</div><div class="ttdoc">Init. </div><div class="ttdef"><b>Definition:</b> <a href="b__os_8c_source.html#l00118">b_os.c:118</a></div></div>
<div class="ttc" id="b__os_8h_html"><div class="ttname"><a href="b__os_8h.html">b_os.h</a></div></div>
<div class="ttc" id="group___b_o_s___private___macros_html_ga1e55aed6efd8f6dbaec02548c6ba6b71"><div class="ttname"><a href="group___b_o_s___private___macros.html#ga1e55aed6efd8f6dbaec02548c6ba6b71">bErrorCore</a></div><div class="ttdeci">int bErrorCore(void)</div></div>
<div class="ttc" id="group___b_o_s___private___macros_html_gaf9afd0ae30f6af580ac18395a04d2fb8"><div class="ttname"><a href="group___b_o_s___private___macros.html#gaf9afd0ae30f6af580ac18395a04d2fb8">bTX_Core</a></div><div class="ttdeci">int bTX_Core(void)</div></div>
<div class="ttc" id="group___d_e_v_i_c_e___exported___functions_html_ga404e753d491d3b3e4c6fba215d191fa7"><div class="ttname"><a href="group___d_e_v_i_c_e___exported___functions.html#ga404e753d491d3b3e4c6fba215d191fa7">bDeviceInit</a></div><div class="ttdeci">int bDeviceInit(void)</div><div class="ttdoc">Device Initialize. </div><div class="ttdef"><b>Definition:</b> <a href="b__device_8c_source.html#l00129">b_device.c:129</a></div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.14
</small></address>
</body>
</html>
